import pandas as pd
import json

def write_json(file_name,data):
    with open(file_name, 'w') as json_file:
        json.dump(data, json_file)


def set_data_json(filename='data.xlsx'):
    DATA=dict()
    dataDf=pd.read_excel(filename)
    for k,v in dataDf.to_dict().items():
        DATA[k]=v[0]

    DATA['product_mz']=list(map(lambda x:float(x.strip("'"))
                                ,DATA['product_mz'].split(";")))
    DATA['product_intensity']=list(map(lambda x:float(x.strip("'"))
                                ,DATA['product_intensity'].split(";")))
    
    write_json("data.json",DATA)


if __name__ == "__main__":
    set_data_json("data.xlsx")